﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="../layui/lib/layui-v2.6.3/css/layui.css" rel="stylesheet" />
    <link href="../layui/css/public.css" rel="stylesheet" />
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">

            <fieldset class="table-search-fieldset">
                <legend>搜索信息</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <div class="layui-form layuimini-form" lay-filter="formTest">
                        <div class="layui-form-item">
                            <label class="layui-form-label">状态：</label>
                            <div class="layui-input-inline">
                                <select id="service" name="LeaderId" lay-verify="required" class="select">
                                    <option value="0">请选择搜索状态</option>
                                    <option value="1">同意</option>
                                    <option value="2">驳回</option>
                                    <option value="3">审核中</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>

            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    @*<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>*@
                    @*<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>*@
                </div>
            </script>

            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

            <script type="text/html" id="currentTableBar">
                @*<a class="layui-btn layui-btn-xs layui-btn layui-btn-normal data-count-delete layui-btn layui-btn-radius " lay-event="lossssg">555</a>*@

                {{# if(d._reviewStatus=="同意" || d._reviewStatus=="已被他人审核") {}}
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete layui-btn layui-btn-radius layui-btn-disabled">已申核</a>
                {{# }else if(d._reviewStatus=="驳回"){ }}
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete layui-btn layui-btn-radius layui-btn-disabled">已驳回</a>
                {{# }else if( d._reviewStatus=="作废"){ }}
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete layui-btn layui-btn-radius layui-btn-disabled">已作废</a>
                {{# }else{ }}
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete layui-btn-radius" lay-event="edit" style="margin-left: 10px;">申核</a>
                {{# } }}
                <a class="layui-btn layui-btn-xs layui-btn layui-btn-normal data-count-delete layui-btn layui-btn-radius " lay-event="log">日志</a>
            </script>

        </div>
    </div>
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/layui/lib/layui-v2.6.3/layui.js"></script>

    <script>
        layui.use(['form', 'table'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table;
            //列表
            search('/WorkFlow_InstanceStep/getWorkFlow_InstanceStepList')
            // 监听搜索操作
            form.on('submit(data-search-btn)', function (data) {
                search('/WorkFlow_InstanceStep/getWorkFlow_InstanceStepList?workFlow_InstanceStepName=' + data.field.Name)
            });

            function search(url) {
                table.render({
                    elem: '#currentTableId',
                    url: url,
                    toolbar: '#toolbarDemo',
                    defaultToolbar: ['filter', 'exports', 'print', {
                        title: '提示',
                        layEvent: 'LAYTABLE_TIPS',
                        icon: 'layui-icon-tips'
                    }],
                    cols: [[
                        { type: "checkbox", minWidth: 50 },
                        { field: 'id', Width: 80, title: 'ID', hide: true },
                        { field: '_reviewerName', minWidth: 80, title: '审核人', },
                        { field: '_instanceId', minWidth: 80, title: '物资模板', },
                        { field: '_consumableName', minWidth: 80, title: '申请物资名称', },
                        { field: '_reviewStatus', minWidth: 80, title: '审核状态', },
                        { field: '_reviewReason', minWidth: 80, title: '理由', },
                        //{ field: '_beforeStepId', minWidth: 80, title: '上一个步骤', },
                        { field: '_reviewTime', minWidth: 80, title: '审核时间', },
                        { field: '_createTime', minWidth: 80, title: '添加时间', sort: true },
                        { title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center" }
                    ]],
                    limits: [10, 15, 20, 25, 50, 100],
                    limit: 10,
                    page: true,
                    skin: 'line'
                });
            }

            /**
             * toolbar监听事件
             */
            table.on('toolbar(currentTableFilter)', function (obj) {
                if (obj.event === 'add') {  // 监听添加操作
                    var index = layer.open({
                        title: '添加申请人',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['100%', '100%'],
                        content: '/WorkFlow_InstanceStep/AddWorkFlow_InstanceStepView',
                        end: function () {
                            //刷新列表
                            table.reload('currentTableId', {
                                page: {
                                    curr: 1
                                }
                                , where: {
                                }
                            }, 'data');
                        }
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                }
            });

            table.on('tool(currentTableFilter)', function (obj) {
                var data = obj.data;

                console.log(data)
                if (obj.event === 'edit') {
                    console.log(data._reviewerName)
                    var index = layer.open({
                        title: '申核',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['100%', '100%'],
                        content: '/WorkFlow_InstanceStep/UpdataWorkFlow_InstanceStepView?id=' + data.id + "&_instanceIds=" + data._instanceIds,
                        end: function () {
                            //刷新列表
                            table.reload('currentTableId', {
                                page: {
                                    curr: 1
                                }
                                , where: {
                                }
                            }, 'data');
                        }
                    });

                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    return false;
                } else if (obj.event === 'log') {
                    console.log(data._reviewerName)
                    var index = layer.open({
                        title: '员工："' + data._reviewerName + ' "  的申核日志',
                        type: 2,
                        shade: 0.2,
                        maxmin: true,
                        shadeClose: true,
                        area: ['70%', '80%'],
                        content: '/WorkFlow_InstanceStep/LogView?id=' + data._instanceIds,
                        end: function () {
                            //刷新列表
                            table.reload('currentTableId', {
                                page: {
                                    curr: 1
                                }
                                , where: {
                                }
                            }, 'data');
                        }
                    });

                    $(window).on("resize", function () {
                        layer.full(index);
                    });
                    return false;
                } else if (obj.event === 'lossssg') {
                    console.log(data._instanceIds)
                    $.ajax({
                        url: "/WorkFlow_InstanceStep/getLogList",
                        type: "get",
                        data: { InstanceId: data._instanceIds },
                        success: function (res) {
                            console.log(res)
                        }
                    })
                }
            });

        });</script>

</body>
</html>